package pl.edu.pjwstk.kor.database.init;

import java.util.ArrayList;
import java.util.List;

import pl.edu.pjwstk.kor.model.Employee;

public class EmployeeInitalizer extends PersonInitalizer<Employee> {

	public EmployeeInitalizer() {
		super(Employee.class);
	}

	@Override
	public List<Employee> initData() throws Exception {
		List<Employee> result = new ArrayList<Employee>();
		
		List<Employee> boss = new ArrayList<Employee>();
		List<Employee> manager = new ArrayList<Employee>();
		List<Employee> clerk = new ArrayList<Employee>();
		
		for(int i = 0 ; i < 10; i++) {
			boss.add(createRandomEmployee("szef"));
		}
		
		for(int i = 0 ; i < 50; i++) {
			Employee m = createRandomEmployee("manager");
			m.setBoss(selectRandom(boss, random));
			manager.add(m);
		}
		
		for(int i = 0 ; i < 100; i++) {
			Employee c = createRandomEmployee("sprzedawca");
			c.setBoss(selectRandom(manager, random));
			clerk.add(c);
		}
		
		result.addAll(boss);
		result.addAll(manager);
		result.addAll(clerk);
		
		return result;
	}

	protected Employee createRandomEmployee(String role) {
		Employee e =  super.createRandomPerson();
		e.setJob(role);
		return e;
	}
}
